<script setup lang="ts">
import { ref } from 'vue'
import { Edit, Document, Setting, InfoFilled, Calendar, View, Star, ChatDotRound, Delete } from '@element-plus/icons-vue'
// 模拟用户数据
const userInfo = ref({
  name: '啦啦啦',
  avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
  bio: '热爱编程与写作的开发者，分享技术心得和生活感悟',
  followers: 128,
  following: 56,
  articles: 42,
  likes: 368
})

// 模拟文章数据
const articles = ref([
  {
    id: 1,
    title: 'Vue3 + TypeScript 最佳实践',
    content: '分享在Vue3项目中使用TypeScript的一些经验和技巧...',
    date: '2024-01-15',
    likes: 24,
    comments: 8,
    views: 156
  },
  {
    id: 2,
    title: 'Element Plus 自定义主题指南',
    content: '详细讲解如何定制Element Plus的主题色彩，打造个性化界面...',
    date: '2024-01-12',
    likes: 18,
    comments: 5,
    views: 89
  },
  {
    id: 3,
    title: '前端工程化配置实战',
    content: '从零配置一个现代化的前端项目，包含ESLint、Prettier等工具...',
    date: '2024-01-10',
    likes: 32,
    comments: 12,
    views: 203
  }
])
</script>

<template>
  <div class="user-profile">
    <!-- 顶部个人信息区域 -->
    <el-card class="profile-header" shadow="never">
      <div class="header-content">
        <div class="avatar-section">
          <el-avatar :size="100" :src="userInfo.avatar" class="user-avatar" />
          <div class="user-stats">
            <div class="stat-item">
              <span class="stat-number">{{ userInfo.followers }}</span>
              <span class="stat-label">粉丝</span>
            </div>
            <div class="stat-item">
              <span class="stat-number">{{ userInfo.following }}</span>
              <span class="stat-label">关注</span>
            </div>
            <div class="stat-item">
              <span class="stat-number">{{ userInfo.articles }}</span>
              <span class="stat-label">文章</span>
            </div>
            <div class="stat-item">
              <span class="stat-number">{{ userInfo.likes }}</span>
              <span class="stat-label">获赞</span>
            </div>
          </div>
        </div>
        
        <div class="info-section">
          <h1 class="username">{{ userInfo.name }}</h1>
          <p class="user-bio">{{ userInfo.bio }}</p>
          <div class="action-buttons">
            <el-button type="primary" class="action-btn">
              <el-icon><Edit /></el-icon>
              编辑资料
            </el-button>
            <el-button class="action-btn">
              <el-icon><Document /></el-icon>
              管理文章
            </el-button>
            <el-button class="action-btn">
              <el-icon><Setting /></el-icon>
              账号设置
            </el-button>
          </div>
        </div>
      </div>
    </el-card>

    <!-- 主要内容区域 -->
    <div class="profile-main">
      <!-- 左侧区域（暂时留空） -->
      <el-card class="left-panel" shadow="never">
        <template #header>
          <div class="panel-header">
            <el-icon><InfoFilled /></el-icon>
            <span>个人空间</span>
          </div>
        </template>
        <div class="placeholder-content">
          <el-empty description="这里还没有内容哦" :image-size="80">
            <el-button type="primary">探索更多</el-button>
          </el-empty>
        </div>
      </el-card>

      <!-- 右侧文章列表 -->
      <el-card class="right-panel" shadow="never">
        <template #header>
          <div class="panel-header">
            <el-icon><Document /></el-icon>
            <span>发布的文章</span>
          </div>
        </template>
        
        <div class="articles-list">
          <div 
            v-for="article in articles" 
            :key="article.id" 
            class="article-item"
          >
            <div class="article-main">
              <h3 class="article-title">{{ article.title }}</h3>
              <p class="article-content">{{ article.content }}</p>
              <div class="article-meta">
                <span class="meta-item">
                  <el-icon><Calendar /></el-icon>
                  {{ article.date }}
                </span>
                <span class="meta-item">
                  <el-icon><View /></el-icon>
                  {{ article.views }}
                </span>
                <span class="meta-item">
                  <el-icon><Star /></el-icon>
                  {{ article.likes }}
                </span>
                <span class="meta-item">
                  <el-icon><ChatDotRound /></el-icon>
                  {{ article.comments }}
                </span>
              </div>
            </div>
            <div class="article-actions">
              <el-button text class="action-btn">
                <el-icon><Edit /></el-icon>
                编辑
              </el-button>
              <el-button text class="action-btn">
                <el-icon><Delete /></el-icon>
                删除
              </el-button>
            </div>
          </div>
        </div>
      </el-card>
    </div>
  </div>
</template>

<style scoped>
.user-profile {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

/* 顶部个人信息区域 */
.profile-header {
  margin-bottom: 20px;
  border: 1px solid #e4e7ed;
  border-radius: 12px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.header-content {
  display: flex;
  gap: 40px;
  align-items: flex-start;
}

.avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.user-avatar {
  border: 4px solid #e4e7ed;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.user-stats {
  display: flex;
  gap: 24px;
  text-align: center;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-number {
  font-size: 18px;
  font-weight: 600;
  color: #3b82f6;
}

.stat-label {
  font-size: 12px;
  color: #64748b;
}

.info-section {
  flex: 1;
}

.username {
  font-size: 28px;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 12px 0;
}

.user-bio {
  color: #64748b;
  line-height: 1.6;
  margin-bottom: 20px;
  font-size: 14px;
}

.action-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.action-btn {
  border-radius: 6px;
  padding: 10px 16px;
  border: 1px solid #e2e8f0;
}

.action-btn:first-child {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border: none;
  color: white;
}

.action-btn:first-child:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.action-btn:not(:first-child):hover {
  border-color: #3b82f6;
  color: #3b82f6;
}

/* 主要内容区域 */
.profile-main {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
}

.left-panel,
.right-panel {
  border: 1px solid #e4e7ed;
  border-radius: 12px;
  background: #ffffff;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #1e293b;
}

.panel-header .el-icon {
  color: #3b82f6;
}

.placeholder-content {
  padding: 40px 0;
}

/* 文章列表 */
.articles-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.article-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px;
  border: 1px solid #f1f5f9;
  border-radius: 8px;
  transition: all 0.3s ease;
  background: #f8fafc;
}

.article-item:hover {
  border-color: #3b82f6;
  box-shadow: 0 2px 12px rgba(59, 130, 246, 0.1);
  transform: translateY(-2px);
}

.article-main {
  flex: 1;
}

.article-title {
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 8px 0;
  cursor: pointer;
  transition: color 0.3s ease;
}

.article-title:hover {
  color: #3b82f6;
}

.article-content {
  color: #64748b;
  line-height: 1.5;
  margin-bottom: 12px;
  font-size: 14px;
}

.article-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: #94a3b8;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.meta-item .el-icon {
  color: #64748b;
}

.article-actions {
  display: flex;
  gap: 8px;
}

.article-actions .action-btn:hover {
  color: #3b82f6;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .profile-main {
    grid-template-columns: 1fr;
  }
  
  .header-content {
    flex-direction: column;
    text-align: center;
    gap: 20px;
  }
  
  .user-stats {
    justify-content: center;
  }
  
  .action-buttons {
    justify-content: center;
  }
  
  .article-item {
    flex-direction: column;
    gap: 12px;
  }
  
  .article-actions {
    align-self: flex-end;
  }
}
</style>